From bb48205aae34e6bf0ce1810ab784bf36f00bc4d2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Florian=20M=C3=BCllner?= Date: Mon, 25 Nov 2019 01:49:04 +0100 Subject: [PATCH] extensions-tool: Fix removing from settings list When removing a string from a settings list, we iterate over all existing entries and copy all strings except the one that's being removed to a new list, which is then written to GSettings. However we currently always increment the index, so we end up with a NULL entry in place of the removed entry, which is then interpreted as the end of the list. In other words, we also remove all entries that follow the removed string. Fix this by looping over the list entries instead of the index, and only increment the index for entries we copy. https://gitlab.gnome.org/GNOME/gnome-shell/issues/1946 --- src/extensions-tool/main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/extensions-tool/main.c b/src/extensions-tool/main.c index 7cc83de95..e9a457018 100644 --- a/src/extensions-tool/main.c +++ b/src/extensions-tool/main.c @@ -142,9 +142,10 @@ settings_list_remove (GSettings *settings, n_values = g_strv_length (list); new_value = g_new0 (char *, n_values); - for (i = 0, s = (const char **)list; i < n_values; i++, s++) + i = 0; + for (s = (const char **)list; *s != NULL; s++) if (!g_str_equal (*s, value)) - new_value[i] = g_strdup (*s); + new_value[i++] = g_strdup (*s); g_settings_set_strv (settings, key, (const char **)new_value); g_settings_sync (); -- 2.39.5